#include <iostream>
#include <memory>
#include "Server.hpp"
#include "CommandExcute.hpp"
#include "Dict.hpp"

void Useage(const char* proc)
{
    printf("Useage error\n\t %s Port\n", proc);
}

int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        Useage(argv[0]);
        return 1;
    }
    uint16_t port = std::stoi(argv[1]);

    // 命令行执行服务
    // CommandExcute cmdExcute("./legalInstruction.txt");
    // task_t cmd = std::bind(&CommandExcute::Excute, &cmdExcute, std::placeholders::_1);

    // std::unique_ptr<TCPServer> server = std::make_unique<TCPServer>(port, cmd);



    // 翻译功能
    Dict dict("./Dict.txt");
    task1_t d = std::bind(&Dict::translate, &dict, std::placeholders::_1, std::placeholders::_2);

    std::unique_ptr<TCPServer> server = std::make_unique<TCPServer>(port, d);





    server->InitServer();
    server->Loop();
    
    return 0;
}